<template>
  <div class='container'>
    <el-dialog
  title="题目审核"
  :visible="checkShow"
  width="30%"
  @close='checkClose'
  >
  <div class="radio">
  <el-radio v-model="fromData.chkState"  label="1">通过</el-radio>
  <el-radio v-model="fromData.chkState"  label="2">拒绝</el-radio>
  </div>
  <div class="textarea">
    <el-input
  type="textarea"
  :rows="2"
  placeholder="请输入审核意见"
  v-model="fromData.chkRemarks">
</el-input>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button @click='checkClose'>取 消</el-button>
    <el-button type="primary" @click="confirm">确 定</el-button>
  </span>
</el-dialog>

  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  data () {
    return {
      fromData: {
        id: '',
        chkState: '1',
        chkRemarks: ''
      }
    }
  },
  props: {
    checkShow: {
      type: Boolean,
      require: true
    },
    onlist: {
      type: Object,
      require: true
    }
  },
  methods: {
    checkClose () {
      // 告诉父组件关闭弹窗
      this.$emit('checkClose', false)
      this.fromData = {
        id: '',
        chkState: '1',
        chkRemarks: ''
      }
    },
    async confirm () {
      if (!this.fromData.chkRemarks.trim()) {
        this.$message({
          message: '请填写审核意见!',
          type: 'warning'
        })
        return
      }
      this.fromData.id = this.onlist.id
      this.fromData.chkState = +this.fromData.chkState
      await choiceCheck(this.fromData)
      this.$message.success('操作成功!')
      this.checkClose()
    }
  }
}
</script>

<style scoped lang='scss'>
  .container{
    .textarea{
      padding: 20px 10px;
    }
     ::v-deep .el-dialog__footer{
    text-align: right;
  }
  }
</style>
